/**
 * 
 */
package com.and.xmppsdk.util;

import org.drl.xmpp.util.StringHelper;

import android.content.Context;
import android.widget.Toast;

/**
 * @author Administrator
 * 
 */
public final class ToastHelper {

	private static Toast mToast = null;
	private static Context mContext = null;

	public final static void init(Context ctx) {
		mContext = ctx;
	}

	public final static void showTet(Context ctx, String text) {
		if (mContext == null) {
			mContext = ctx;
		}
		if (mToast == null) {
			mToast = Toast.makeText(mContext, text, Toast.LENGTH_SHORT);
		} else {
			mToast.setText(text);
		}
		mToast.show();
	}

	public final static void showException(Context ctx, String tag, Throwable t) {
		if (mContext == null) {
			mContext = ctx;
		}
		if (mToast == null) {
			mToast = Toast.makeText(mContext,
					tag + "\n" + StringHelper.exceptionToString(t),
					Toast.LENGTH_SHORT);
		} else {
			mToast.setText(tag + "\n" + StringHelper.exceptionToString(t));
		}
		mToast.show();
	}

}
